/*
 * =============================================================================
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <eirikb@google.com> wrote this file. As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return Eirik Brandtzæg
 * =============================================================================
 */
package no.eirikb.roboco.terminal.element;

import java.util.StringTokenizer;
import no.eirikb.roboco.terminal.Terminal;

/**
 *
 * @author eirikb
 * @author <a href="mailto:eirikb@google.com">eirikb@google.com</a>
 */
public abstract class Element {

    private Terminal terminal;
    private int x;
    private int y;
    private int width;
    private int height;

    public Element(Terminal terminal, int x, int y, StringTokenizer st) {
        this.terminal = terminal;
        this.x = x;
        this.y = y;
        int i = 0;
        while (st.hasMoreTokens()) {
            String s = st.nextToken();
            switch (i) {
                case 0:
                    width = Integer.parseInt(s);
                    break;
                case 1:
                    height = Integer.parseInt(s);
                    break;
            }
            i++;
        }
    }

    public void sendLine(String line) {
        getTerminal().getServer().sendLagText("\r\n" + line);
    }

    public Terminal getTerminal() {
        return terminal;
    }

    public void read(int c) {
    }

    public void init() {
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }
}
